#include "slist.h"
template<typename T>
int InitializeStaticList (T* list,unsigned int num, char* (*_malloc)(unsigned int))
{
  list->num = num;
  list->content = (listnode*)(_malloc(sizeof(staticlist) * num));
  list->head = list->content;
  list->tail = &(list->content[num - 1]);
  return 1;
}

template<typename T>
static T * _FindListNode(T* node,unsigned int num)
{
  return (num > 0 ?
	  _FindListNode(node->next,num-1)
	  :
	  node);
}
template<typename T>
typename T::Ntype * FindStaticList(T* list,unsigned int num)
{
  return _FindListNode(list->head,num);
} 

template<typename T>
int UpStaticListNode(T* list,typename T::Ntype * node)
{
  RemoveListNode(node);
  list->head->pre = node;
  node->next = list->head;
  list->head = node;
  return 1;
}

template<typename T>
int DownStaticListNode(T* list,typename T::Ntype * node)
{
  RemoveListNode(node);
  InsertListNode(list->tail,node);
  list->tail = node;
  return 1;
}

template<typename T>
inline typename T::Ntype * GetLastStaticListNode(T* list)
{
  return list->tail;
}
